package mvpfoot.adapter;

import android.media.Image;
import android.net.Uri;
import android.support.v7.widget.RecyclerView;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ImageView;
import android.widget.LinearLayout;

import com.bumptech.glide.Glide;
import com.example.click.mvpfoot.R;

import java.net.URI;
import java.util.List;

import mvpfoot.MyApplication;
import mvpfoot.entity.ZhiHuDaily;
import mvpfoot.entity.ZhihuStory;

/**
 * Created by Chen qin lang on 2017/1/13.
 */
public class PersonINfoAdapter extends RecyclerView.Adapter {
    public List<ZhihuStory> zhihuStories;

    public PersonINfoAdapter(List<ZhihuStory> zhihuStories) {
        this.zhihuStories = zhihuStories;
    }

    @Override
    public RecyclerView.ViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
        LinearLayout linearLayout = (LinearLayout) View.inflate(parent.getContext(), R.layout.item_person, null);
        return new MyHolder(linearLayout);
    }

    @Override
    public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
        MyHolder myHolder = (MyHolder) holder;
        Glide.with(MyApplication.application).fromUri().load(Uri.parse(zhihuStories.get(position).getImages().get(0))).into(myHolder.image);

    }

    @Override
    public int getItemCount() {
        return zhihuStories==null?0:zhihuStories.size();
    }
    static  class  MyHolder extends RecyclerView.ViewHolder{
        public ImageView image;
        public MyHolder(View itemView) {
            super(itemView);
            image=(ImageView) itemView.findViewById(R.id.item_image);
        }
    }
}
